<%@page import="java.util.List"%>
<%@page import="com.jfinal.plugin.activerecord.Page"%>
<%@page import="com.hongye.app.model.EmployeeManageModel"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" isELIgnored="false"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!doctype html>
<html class="fixed">

	<head>

		<!-- Basic -->
		<meta charset="UTF-8">
		<meta name="keywords" content="HTML5 Admin Template" />
		<meta name="description" content="Porto Admin - Responsive HTML5 Template">
		<meta name="author" content="okler.net">
		<!-- Mobile Metas -->
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<!-- Web Fonts  -->
		<!-- Vendor CSS -->
		<link rel="stylesheet" href="../admin/css/bootstrap.css" />
		<link rel="stylesheet" href="../admin/css/font-awesome/css/font-awesome.css" />
        <link rel="stylesheet" href="../admin/css/select2.css" />
		<!-- Theme CSS -->
		<link rel="stylesheet" href="../admin/css/theme.css" />
		<!-- Skin CSS -->
		<link rel="stylesheet" href="../admin/css/default.css" />
		<!-- Theme Custom CSS -->
		<!-- Theme Custom ../admin/css -->
		<script src="../admin/js/modernizr.js"></script>
	</head>

	<body>
		<section role="main" class="content-body" style="margin-top: 50px;">
			<!-- start: page -->
			<section class="panel">
				<header class="panel-heading">
					<h2 class="panel-title">员工统计</h2>
				</header>
				<div class="panel-body">
					<div class="row">
						<div class="col-sm-6">
							<div class="mb-md">
								<button id="addToTable" class="btn btn-primary" onclick="add();">添加新员工<i class="fa fa-plus"></i></button>
							</div>
						</div>
					</div>
					<div id="add" style="display:none"><br>
						姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名：<input id="e_name" type="text" name="e_name" />
						&nbsp;&nbsp;性别：
							<SELECT id="e_sex" style="width:100" name="e_sex" selectedIndex="$!{e_sex}"> 
								<OPTION value="0">男</OPTION> 
								<OPTION value="1">女</OPTION> 
							</SELECT> 
						&nbsp;&nbsp;部门：<SELECT id="department" style="width:100" name="department" selectedIndex="$!{department}"> 
								<OPTION value="1">财务部</OPTION> 
								<OPTION value="2">研发部</OPTION> 
								<OPTION value="3">销售部</OPTION> 
							</SELECT> 
						<p>职&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;位：<input id="place" type="text" name="place" /></p>
						<p>联系电话：<input id="e_phone" type="text" name="e_phone"  /></p>
						<p>员工编号：<input id="employee_num" type="text" name="employee_num" placeholder="0001" /><font color="#a11" >*4位数字</font></p>
						<a class="btn btn-facebook mb-md ml-xs mr-xs" onclick="agreeadd();">确定提交 </a>
                   		<a class="btn btn-facebook mb-md ml-xs mr-xs" onclick="hid();">取消</a>
					</div>
					<table class="table table-bordered table-striped mb-none" id="datatable-default">
						<thead>
							<tr>
								<th class="hidden-phone center">序号</th>
								<th class="hidden-phone center">部门名称</th>
								<th class="hidden-phone center">职位</th>
								<th class="hidden-phone center">员工姓名</th>
								<th class="hidden-phone center">员工性别</th>
								<th class="hidden-phone center">员工联系电话</th>
								<th class="hidden-phone center">员工编号</th>
								<th class="hidden-phone center">邀请数量</th>
								<th class="hidden-phone center">在职状态</th>
								<th class="hidden-phone center">操作</th>
							</tr>
						</thead>
						<tbody>
							<%List<EmployeeManageModel> list = (List)request.getAttribute("employeelist");
										for(int i=1;i<=list.size();i++){
											EmployeeManageModel em = list.get(i-1);
										%>
										<tr class="gradeA">
											<td class="center hidden-phone"><%=i %></td>
											<td class="center hidden-phone"><%int department=em.getInt("department"); 
											if(department==1){out.println("财务部");}
											else if(department==2){out.println("研发部");}
											else if(department==3){out.println("销售部");}%></td></td>
											<td class="center hidden-phone"><%=em.get("place") %></td>
											<td class="center hidden-phone"><%=em.get("e_name") %></td>
											<td class="center hidden-phone"><%int e_sex=em.getInt("e_sex"); 
											if(e_sex==0){out.println("男");}else{out.println("女");} %></td>
											<td class="center hidden-phone"><%=em.get("e_phone") %></td>
											<td class="center hidden-phone"><%=em.get("employee_num") %></td>
											<td class="center hidden-phone"><%=em.get("invite_num") %></td>
											<td class="center hidden-phone"><%int status=em.getInt("status"); 
											if(status==0){out.println("在职");}else{out.println("离职");} %></td>
											<td class="center hidden-phone">
												<a href="./employeeDetail?employee_num=<%=em.get("employee_num")%>">查看</i></a>
											</td>
										</tr>
										<%} %>
						</tbody>
					</table>
				</div>
			</section>
		</section>
		<!-- Specific Page Vendor -->
		<!-- Vendor -->
		<script src="../admin/js/jquery.js"></script>
		<script src="../admin/js/layer.js"></script>
		<script src="../admin/js/jquery-browser-mobile/jquery.browser.mobile.js"></script>
		<script src="../admin/js/bootstrap/js/bootstrap.js"></script>
		<script src="../admin/js/nanoscroller/nanoscroller.js"></script>
		<script src="../admin/js/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
		<script src="../admin/js/magnific-popup/magnific-popup.js"></script>
		<script src="../admin/js/jquery-placeholder/jquery.placeholder.js"></script>
		
		<!-- Specific Page Vendor -->
	<!--	<script src="js/select2.js"></script>-->
		<script src="../admin/js/jquery-datatables/media/js/jquery.dataTables.js"></script>
		<script src="../admin/js/jquery-datatables-bs3/assets/js/datatables.js"></script>
		
		<!-- Theme Base, Components and Settings -->
		<script src="../admin/js/theme.js"></script>
		
		<!-- Theme Custom -->
		<script src="../admin/js/theme.custom.js"></script>
		
		<!-- Theme Initialization Files -->
		<script src="../admin/js/theme.init.js"></script>


		<!-- Examples -->
		<script src="../admin/js/tables/examples.datatables.default.js"></script>
		<script src="../admin/js/tables/examples.datatables.row.with.details.js"></script>
		<script src="../admin/js/tables/examples.datatables.tabletools.js"></script>
		<script type="text/javascript">
			//显示添加div
			function add(){
				$("#add").css('display','block'); 
			}
			//隐藏添加div
			function hid(){
				$("#add").css('display','none'); 
			}
			//添加
			function agreeadd(){				
				var e_name = $("#e_name").val();
				var e_sex = $("#e_sex").val();
				var department = $("#department").val();
				var place = $("#place").val();
				var e_phone = $("#e_phone").val();
				var employee_num = $("#employee_num").val();
				$.get('../employee/addNewEmployee?e_name='+e_name
						+'&e_sex='+e_sex
						+'&department='+department
						+'&place='+place
						+'&e_phone='+e_phone
						+'&employee_num='+employee_num
						,function(data){
							if(data=='suc'){
								location.href='../employee/employeeManageView';
							}else if(data=='fal'){
								layer.msg('更新失败...', {icon: 5});
							}else if(data=='re'){
								layer.msg('员工编码已存在', {icon: 5});
							}
				});
			}
			
		</script>
	</body>

</html>